package method5;

/**
 * 内部类，线程安全
 * 优点：打到和双检查一样的效果，Singleton加载时并不会加载SingletonHolder，只有调用getInstance()方法才会加载
 */
public class Singleton {

	private static Singleton instance;
	
	private Singleton(){}

	private static class SingletonHolder {
		private static final Singleton SINGLETON = new Singleton();
	}

	public Singleton getInstance() {
		return SingletonHolder.SINGLETON;
	}
}
